home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1063 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: in2.uu.net!usc!comserv-i-62
  2. From: wawda@scf.usc.edu (Abu Wawda)
  3. Newsgroups: comp.lang.c
  4. Subject: Help with gettng 2 chars into an integer!
  5. Date: 11 Jan 1996 07:33:53 GMT
  6. Organization: University of Southern California, Los Angeles, CA
  7. Sender: wawda@comserv-i-62.usc.edu
  8. Message-ID: <4d2eh1$7pm@usc.edu>
  9. NNTP-Posting-Host: comserv-i-62.usc.edu
  10.  
  11.  
  12. Hi. I can't seem to figure out how to do this. Basically I have to chars that 
  13. I want to put into a 2-byte integer. It seems easy at first, but I can't seem 
  14. to figure out to do it with the bit-fidling operators (shifting or masking). 
  15. Simple put, I'd like to do:
  16.  
  17.     char a,b;
  18.     int c;
  19.  
  20.     a = 'A';
  21.     b = 'B';
  22.     c = ? /* the first byte in c should contain the value of a, and the 
  23. second byte should contain the value of b */
  24.  
  25. Please help! Thanks in advance,
  26.  
  27. =====================================================================.
  28. | Abu Wawda | wawda@scf.usc.edu |   http://www-scf.usc.edu/~wawda/    |
  29. | ------------------------------------------------------------------- |
  30. | "The world is a comedy to those who think, |       Live Long        |
  31. |  a tragedy to those who feel." -H. Walpole |      and Prosper.      |
  32. `====================================================================='
  33.